<template>
  <div class="head">
    <div class="head-left" @click="$router.go(-1)">
      <van-icon name="arrow-left" color="#666" size="22" />
    </div>
    <div class="logo">{{ title }}</div>
    <div class="head-right">
      <!-- 气包弹出框 -->
      <van-popover
        placement="bottom-end"
        v-model="showPopover"
        trigger="click"
        :actions="actions"
        @select="onSelect"
      >
        <template #reference>
          <van-icon name="apps-o" color="#666" size="24" />
        </template>
      </van-popover>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    title: {
      type: String,
      required: true
    }
  },
  data () {
    return {
      checked: true,
      showPopover: false, // 控制弹出框的显示
      actions: [
        { text: '首页', icon: 'wap-home-o', path: '/' },
        { text: '分类', icon: 'apps-o', path: '/cate' },
        { text: '购物车', icon: 'shopping-cart-o', path: '/cart' },
        { text: '我的', icon: 'smile-o', path: '/user' }
      ],
      token: localStorage.getItem('token')
    }
  },
  methods: {
    onSelect (action) {
      this.$router.push(action.path)
    }
  }
}
</script>

<style lang="scss" scoped>
.head {
  position: fixed;
  top: 0;
  left: 0;
  height: 44px;
  display: flex;
  padding: 0 20px 0 12px;
  box-sizing: border-box;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  width: 100%;
  border-bottom: 1px solid #e9ecf0;
  background-color: #fff;
  img {
    width: 150px;
    height: 20px;
  }
  .icon {
    font-size: 22px;
  }
}
</style>
